<?php
namespace app\admin\controller;
use app\BaseController;
use app\common\entity\BackResult;
use app\common\service\AdminService;
use app\Request;

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/10/9 0009
 * Time: 21:28
 */

class Login extends BaseController
{
    public function login(Request $request)
    {
        $username = $request->post("username");
        $password = $request->post("password");
        $service = new AdminService();
        $token = $service->login($username,$password,3600 * 2);
        if($token){
            return BackResult::success(['token'=>$token],"登录成功");
        }
        return BackResult::error([],"登录失败");
    }
}
